﻿using Airborne.ScrumPoker.Presentation.AutomationTests.Artifacts;
using Core;
using Core.UIItems.WindowItems;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Airborne.ScrumPoker.Presentation.AutomationTests.Master
{
    [TestClass]
    public class TimerTestFixture : TestBase
    {

        protected static Application MasterApplication { get; set; }
        protected static Window ProjectOwnerView { get; set; }


        [ClassInitialize]
        public static void ClassInitialise(TestContext context)
        {
            MasterApplication = GetApplication(TestConstants.MasterApplication);
        }

        [ClassCleanup]
        public static void ClassCleanup()
        {
            Close(MasterApplication);
        }

        [TestInitialize]
        public void TestInit()
        {
            ProjectOwnerView = OpenWindow(MasterApplication, "shellProjectOwnerView");
        }

        [TestMethod]
        public void TimerStartTest()
        {
            ScrumPokerProjectOwner owner = new ScrumPokerProjectOwner(ProjectOwnerView);
            owner.TimerTextBox.Text = "100";
            Assert.IsFalse(owner.StopTimerButton.Enabled);

            owner.StartTimerButton.Click();

            Assert.IsFalse(owner.ResetVotesTimerButton.Enabled);
            Assert.IsFalse(owner.ShowVotesTimerButton.Enabled);
            Assert.IsFalse(owner.StartTimerButton.Enabled);

            Assert.IsTrue(owner.StopTimerButton.Enabled);
            owner.StopTimerButton.Click();
        }

        [TestMethod]
        public void TimerStopTest()
        {
            ScrumPokerProjectOwner owner = new ScrumPokerProjectOwner(ProjectOwnerView);
            owner.TimerTextBox.Text = "100";
            owner.StartTimerButton.Click();

            Assert.IsFalse(owner.ResetVotesTimerButton.Enabled);
            Assert.IsFalse(owner.ShowVotesTimerButton.Enabled);
            Assert.IsFalse(owner.StartTimerButton.Enabled);

            Assert.IsTrue(owner.StopTimerButton.Enabled);

            owner.StopTimerButton.Click();
            Assert.IsTrue(owner.ResetVotesTimerButton.Enabled);
            Assert.IsTrue(owner.ShowVotesTimerButton.Enabled);
            Assert.IsTrue(owner.StartTimerButton.Enabled);

            Assert.IsFalse(owner.StopTimerButton.Enabled);
        }

    }
}
